package print;

import java.io.*;
import java.util.Properties;
//Properties本质是一个map集合
public class PropertiesDemo1 {
    public static void main(String[] args) throws IOException {
        Properties pt=new Properties();
        pt.setProperty("username","admin");
        pt.setProperty("password","123456");
        final var object = pt.get("password");
        final var username = pt.getProperty("username");
        System.out.println(object);
        System.out.println(username);
        System.out.println(pt);
        for (String key : pt.stringPropertyNames()) {
            System.out.println(key+"---"+pt.getProperty(key));
            System.out.println(key.getBytes());

        }
        FileOutputStream fos=new FileOutputStream("G:\\Javatest2\\print\\config.properties");
        pt.store(fos,"hi");
//        fos.close();


        FileWriter fw=new FileWriter("G:\\Javatest2\\print\\config.properties",true);
        pt.store(fos,"cxq");
        fw.close();

        FileInputStream fis=new FileInputStream("G:\\Javatest2\\print\\config.properties");
        pt.load(fis);
        fis.close();
        System.out.println(pt);

    }
}
